package com.hhh.springai_test.common;

public enum ErrorCode {

    SUCCESS_CODE(200, "响应成功"),
    NOT_FOUND_CODE(404,"请求结果不存在"),
    NO_LOGIN_CODE(401, "未登录"),
    NOT_AUTH_CODE(403, "没有权限"),
    PARAMS_ERROR(400, "请求参数错误"),
    BUSY_ERROR(429, "频繁操作，请稍后再试"),
    SYSTEM_ERROR(500, "系统内部异常"),
    REGISTER_ERROR(426, "注册失败");

    private Integer code;
    private String message;

    ErrorCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static String getMessage(Integer code) {
        for (ErrorCode errorCode : ErrorCode.values()) {
            if (errorCode.getCode().equals(code)) {
                return errorCode.getMessage();
            }
        }
        return null;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }
}
